//
//  MarksView.m
//  StraightTrain
//
//  Created by mk on 16/1/12.
//  Copyright © 2016年 mk. All rights reserved.
//

#import "MarksView.h"

@implementation MarksView



-(int)loadViewGetHighe
{
    for (UIView * viewBtn in [self subviews])
    {
        [viewBtn removeFromSuperview];
    }
    
    NSInteger Y = self.fram_Y;
   
    NSInteger viewW = self.fram_W;
    
    for (int i = 0; i<self.arrMarks.count; i++)
    {
        NSString * strTitle = [self.arrMarks objectAtIndex:i];
        CGSize sizeMax = [strTitle boundingRectWithSize:CGSizeMake(viewW,1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil].size;
        
        UIButton * btnMrk = [UIButton buttonWithType:UIButtonTypeCustom];
        [btnMrk setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
        [btnMrk setContentVerticalAlignment:UIControlContentVerticalAlignmentTop];
        [btnMrk setTitleEdgeInsets:UIEdgeInsetsMake(0,5,0, 0)];
        
        btnMrk.titleLabel.font = [UIFont systemFontOfSize:14];
        btnMrk.titleLabel.numberOfLines = 1000;
        [btnMrk setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        btnMrk.tag = i;
        [btnMrk addTarget:self action:@selector(btnMrkClick:) forControlEvents:UIControlEventTouchUpInside];
        
        int h = (sizeMax.height< 15? 15:sizeMax.height);
        btnMrk.frame = CGRectMake(self.fram_X, Y,viewW,h);
        [self addSubview:btnMrk];
      
        if (i == self.arrMarks.count-1)
        {
             Y = (Y+h);
            return Y;
        }
        else
        Y = (Y+h+10);
    }
    
    return Y;
}

-(void)btnMrkClick:(id)sender
{
 
    if ([self.delegate respondsToSelector:@selector(selectMrk:)])
    {
        [self.delegate selectMrk:sender];
    }
    
}


@end












